package com.kunpeng.weibo.renren;

import com.kunpeng.weibo.renren.api.Admin_API;
import com.kunpeng.weibo.renren.api.Blog_API;
import com.kunpeng.weibo.renren.api.Feed_API;
import com.kunpeng.weibo.renren.api.Friends_API;
import com.kunpeng.weibo.renren.api.Invitations_API;
import com.kunpeng.weibo.renren.api.Notifications_API;
import com.kunpeng.weibo.renren.api.Page_API;
import com.kunpeng.weibo.renren.api.Pay_API;
import com.kunpeng.weibo.renren.api.Photo_API;
import com.kunpeng.weibo.renren.api.Status_API;
import com.kunpeng.weibo.renren.api.User_API;
import com.kunpeng.weibo.renren.param.AccessToken;
import com.kunpeng.weibo.renren.utils.Invoker;

public class RenRen {
	private static RenRen			mRenRen;
	
	private AccessToken mAccessToken;

	public static String			RENREN_APP_URL		= "http://api.renren.com/restserver.do";
	public static String			RENREN_API_VERSION	= "1.0";
	public static String			RENREN_APP_KEY;
	public static String			RENREN_APP_SECRET;
	public static String			RENREN_APP_ID;

	private Invoker		renrenApiInvoker;

	private Friends_API			friendsService;

	private User_API				userService;

	private Admin_API			adminService;

	private Invitations_API		invitationsService;

	private Notifications_API	notificationsService;

	private Page_API				pageService;

	private Status_API			statusService;

	private Blog_API				blogService;

	private Feed_API				feedService;

	private Pay_API				payService;

	private Photo_API			photoService;
	
	private RenRen(){
		renrenApiInvoker = new Invoker();
	}

	public synchronized static RenRen getInstance() {
		if (mRenRen == null) {
			mRenRen = new RenRen();
		}
		return mRenRen;
	}

	public void init(String key, String secret, String id) {
		RENREN_APP_KEY = key;
		RENREN_APP_SECRET = secret;
		RENREN_APP_ID = id;
		mAccessToken = new AccessToken("173001|6.ee01863ca735cebb7b7714bae17baed8.2592000.1327057200-432801017");
	}
	
	public AccessToken getAccessToken() {
//        return "173001|6.ee01863ca735cebb7b7714bae17baed8.2592000.1327057200-432801017";
		return mAccessToken;
    }
	
	public void setAccessToken(AccessToken token){
		this.mAccessToken = token;
	}

	public Friends_API getFriendsService() {
		if (friendsService == null) {
			friendsService = new Friends_API(this.renrenApiInvoker);
		}
		return friendsService;
	}

	public User_API getUserService() {
		if (userService == null) {
			userService = new User_API(this.renrenApiInvoker);
		}
		return userService;
	}

	public Admin_API getAdminService() {
		if (adminService == null) {
			adminService = new Admin_API(this.renrenApiInvoker);
		}
		return adminService;
	}

	public Invitations_API getInvitationsService() {
		if (invitationsService == null) {
			invitationsService = new Invitations_API(this.renrenApiInvoker);
		}
		return invitationsService;
	}

	public Notifications_API getNotificationsService() {
		if (notificationsService == null) {
			notificationsService = new Notifications_API(this.renrenApiInvoker);
		}
		return notificationsService;
	}

	public Page_API getPageService() {
		if (pageService == null) {
			pageService = new Page_API(this.renrenApiInvoker);
		}
		return pageService;
	}

	public Status_API getStatusService() {
		if (statusService == null) {
			statusService = new Status_API(this.renrenApiInvoker);
		}
		return statusService;
	}

	public Blog_API getBlogService() {
		if (blogService == null) {
			blogService = new Blog_API(this.renrenApiInvoker);
		}
		return blogService;
	}

	public Feed_API getFeedService() {
		if (feedService == null) {
			feedService = new Feed_API(this.renrenApiInvoker);
		}
		return feedService;
	}

	public Pay_API getPayService() {
		if (payService == null) {
			payService = new Pay_API(this.renrenApiInvoker);
		}
		return payService;
	}

	public Photo_API getPhotoService() {
		if (photoService == null) {
			photoService = new Photo_API(this.renrenApiInvoker);
		}
		return photoService;
	}
}
